<script src="${basepath}/plugin/qn_jssdk/plupload/plupload.full.min.js"></script>
<script src="${basepath}/plugin/qn_jssdk/qiniu.dev.js"></script>
<script src="${basepath}/plugin/ueditor-min-1.4.3/ueditor.config.js"></script>
<script src="${basepath}/plugin/ueditor-min-1.4.3/ueditor.all.min.js?v=0">
</script>
<%var jstpl = {%>
    <script>
        var form = layui.form;
        var ue = UE.getEditor('desc', {
            zIndex: 199
        });
        imgupload({
            elm: "#logo_upload", // 标签，类名或 ID 不能重复
            thumb_w: 92, // 返回缩略图的宽度
            thumb_h: 92, // 返回缩略图的高度
            fsize: 1.5, // 图片大小限制（MB），默认 100MB
            rery: 3, // 上传失败重试次数，默认 1
            multi: false, // 上传多张
            UploadProgress: function(up, file) {}, // up：对象实例，file：文件上传信息
            FileUploaded: function(img, thumb) {
                    $("#logo").attr("src", thumb);
                    $("input[name='news.cover_img']").val(img);
                } // img：图片原图，thumb：缩略图
        });
        //监听提交
        form.on('submit(formDemo)', function(data) {
            if ($("#cover_img_input_hidden").val() == null || $("#cover_img_input_hidden").val() == "") {
                gx.toast("请上传封面图");
                return false;
            }
            Ajax("/system/notice/saveNews", data.field, function(d) {
                if (d.state == true) {
                    window.location.href = "/system/notice/news";
                } else {
                    gx.alert(d.msg);
                }
            })
        });
    </script>

    <%};%>

        <%var csstpl = {%>

            <%};%>

                <%var title={%>${news.id==null?'添加资讯':'修改资讯'}
                    <%};%>
                        <%layout("../layout/_layout_layui.html",{title:title,jstpl:jstpl,csstpl:csstpl}){ %>
                            <section id="content">
                                <form class="layui-form form-horizontal">
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-form" wid100="">

                                                <input type="hidden" name="news.id" value="${news.id!} ">

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">资讯标题</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="news.title" value="${news.title!}" placeholder="请输入资讯标题" class="layui-input" lay-verify="required" />
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">封面图</label>
                                                    <div class="layui-input-inline">
                                                        <div class="layui-upload">
                                                            <div class="layui-upload-list">
                                                                <% if(news.cover_img==null){ %>
                                                                    <img class="layui-upload-img" id="logo">
                                                                    <% }else{ %>
                                                                        <img class="layui-upload-img" src="${news.cover_img!}?imageView2/1/w/92/h/92" id="logo">
                                                                        <% } %>
                                                                            <p id="demoText"></p>
                                                            </div>
                                                            <input type="hidden" name="news.cover_img" id="cover_img_input_hidden" value="${news.cover_img!}">
                                                            <button type="button" class="layui-btn" id="logo_upload">上传图片</button>
                                                        </div>
                                                    </div>
                                                </div>


                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">资讯类型</label>
                                                    <div class="layui-input-block">
                                                        <select class="layui-input" name="news.type_id" lay-verify="required">
                                                            <option value="">请选择资讯类型</option>
                                                            <%for(t in type_list!){%>
                                                            <option  value="${t.id!}" ${news.type_id==t.id?'selected':''}  >${t.type_name!}</option>
                                                            <%}%>
                                                        </select>
                                                    </div>
                                                </div>


                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">状态</label>
                                                    <div class="layui-input-block">
                                                        <input type="checkbox" value="0" ${news.state!0==0? 'checked': ''} name="news.state" lay-skin="switch" lay-text="正常|禁用">
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">是否首页展示</label>
                                                    <div class="layui-input-block">
                                                        <input type="checkbox" value="1" ${news.is_index!1==1? 'checked': ''} name="news.is_index" lay-skin="switch" lay-text="是|否">
                                                    </div>
                                                </div>


                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">内容</label>
                                                    <div class="layui-input-block">
                                                        <textarea rows="" id="desc" cols="3" name="news.content" lay-verify="required">${news.content!}</textarea>
                                                    </div>
                                                </div>




                                                <div class="layui-form-item">
                                                    <div class="layui-input-block">
                                                        <button type="button" class="layui-btn" lay-submit="" lay-filter="formDemo">${news.id==null?'提交':'保存'}</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </section>

                            <%}%>